package com.cai310.lottery.dao.user;

import java.util.List;

import org.hibernate.Session;
import org.springframework.stereotype.Repository;
import org.springframework.util.Assert;

import com.cai310.lottery.entity.user.User;
import com.cai310.orm.hibernate.HibernateDao;

/**
 * 用户DAO
 * 
 */
@Repository
public class UserDao extends HibernateDao<User, Long> {
	/**
	 * 保存新增或修改的对象.
	 */
	@Override
	public User save(final User entity) {
		Assert.notNull(entity, "entity不能为空");
		if(null!=entity.getId()){
			synchronized (""+entity.getId()) {
				getSession().saveOrUpdate(entity);
			}
		}else{
			getSession().saveOrUpdate(entity);
		}
		return entity;
	}
}
